package jm.java.stringTable;

import java.io.*;
import java.nio.charset.StandardCharsets;

/**
 * @Description StringTable 性能调优
 * @date 2022/3/19 19:07
 */
public class StringTableAdjust {
    public static void main(String[] args) {
        try {
            // 读取一个很大容量的文件，将近48w个单词。
            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream("linux.words"), StandardCharsets.UTF_8));
            String line = null;
            long start = System.nanoTime();
            while (true){
                line = reader.readLine();
                if (line == null){
                    break;
                }
                line.intern();
            }
            System.out.println("cost:" + (System.nanoTime() - start) / 1000000);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
